<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/common/session.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title>贷款及保险线索列表</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no, width=device-width">
	<LINK type="text/css" rel="stylesheet" href="${ctx}/css/default.css" />
	<script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/xtable.js"></script>
	<script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
	<script type="text/javascript" src="${ctx}/dwr/util.js"></script>
	<script type='text/javascript' src='${ctx}/dwr/interface/LoanClueRpcService.js'></script>
	<script type='text/javascript' src='${ctx}/dwr/interface/InsuranceClueRpcService.js'></script>
	<script type="text/javascript" src="${ctx}/js/loading.js"></script>
</head>
<body>
	<center>
		<table style="width: 50%;" cellpadding="5" cellspacing="5">
			<tr>
				<td align="center">
					<lable>贷款类型:</lable> 
					<select id="loanType" style="width: 25%;" name="loanType" onchange="getPage()">
						<option value="1">消费贷</option>
						<option value="2">库存贷</option>
						<option value="3">保险</option>
					</select>
				</td>
			</tr>
		</table>
	</center>
	<div id="loanClueTable">
		<SCRIPT LANGUAGE="JavaScript">
			var loanClueThead = new Array(
				new XThead("车型"),
				new XThead("贷款期数"),
				new XThead("贷款金额"),
				new XThead("贷款时间"),
				new XThead("抵押车辆")
			);

			var loanClueXTable = new XTable("loanClue", loanClueThead, true);

			loanClueXTable.XTbodyArray = function(model) {
				var array = new Array(
					new XTbody("loanClue", model.model.modelName, "string", null, null, "center"),
					new XTbody("loanClue", model.loanPeriod, "string", null, null, "center"),
					new XTbody("loanClue", model.loanAmount, "string", null, null, "center"),
					new XTbody("loanClue", model.loanTime == null ? "" : model.loanTime.Format("yyyy-MM-dd"), "string", null, null, "center"),
					new XTbody("loanClue", model.loanMortgage, "string", null, null, "center")
				);
				return array;
			}

			function getLoanCluePage() {
				var loanClue = new LoanClue();
				loanClue.loanType = dwr.util.getValue("loanType");
				LoanClueRpcService.selectLoanClueList(loanClue, function(list) {
					console.log(list)
					loanClueXTable.addTable(list);
				});
			}
		</SCRIPT>
	</div>
	<div id="insuranceClueTable">
		<SCRIPT LANGUAGE="JavaScript">
			var insuranceClueThead = new Array(
				new XThead("车型"),
				new XThead("城市"),
				new XThead("是否上牌"),
				new XThead("车牌号"),
				new XThead("用户联系方式"),
				new XThead("身份证号")
			);

			var insuranceClueXTable = new XTable("insuranceClue", insuranceClueThead, true);

			var state_hash = {
				"1" : "已上牌",
				"2" : "未上牌"
			}

			insuranceClueXTable.XTbodyArray = function(model) {
				var array = new Array(
					new XTbody("insuranceClue", model.model.modelName, "string", null, null, "center"),
					new XTbody("insuranceClue", model.city.cityName, "string", null, null, "center"),
					new XTbody( "insuranceClue", state_hash[model.clueLicenceStatus], "string", null, null, "center"),
					new XTbody( "insuranceClue", model.clueCarPlant, "string", null, null, "center"),
					new XTbody( "insuranceClue", model.clueMobile, "string", null, null, "center"),
					new XTbody( "insuranceClue", model.clueIdCard, "string", null, null, "center"));
				return array;
			}

			function getInsuranceCluePage() {
				var insuranceClue = new InsuranceClue();
				InsuranceClueRpcService.selectInsuranceClueList(insuranceClue, function(list) {
					console.log(list);
					insuranceClueXTable.addTable(list);
				});
			}
		</SCRIPT>
	</div>
</body>
</html>
<script>
	$(function() {
		$("#loanClueTable").hide();
		$("#loanType").val(3);
		getInsuranceCluePage();
		$("#insuranceClueTable").show();
	});
	function getPage() {
		$("#insuranceClueTable").hide();
		$("#loanClueTable").hide();
		if ($("#loanType").val() == 3) {
			getInsuranceCluePage();
			$("#insuranceClueTable").show();
		} else if ($("#loanType").val() == 1 || $("#loanType").val() == 2) {
			getLoanCluePage();
			$("#loanClueTable").show();
		}
	}
</script>
